<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the MantisPluginTable class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single MantisPluginTable object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a MantisPluginTableMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 *
	 * @package My QCubed Application
	 * @subpackage MetaControls
	 * @property-read MantisPluginTable $MantisPluginTable the actual MantisPluginTable data class being edited
	 * @property QTextBox $BasenameControl
	 * @property-read QLabel $BasenameLabel
	 * @property QIntegerTextBox $EnabledControl
	 * @property-read QLabel $EnabledLabel
	 * @property QIntegerTextBox $ProtectedControl
	 * @property-read QLabel $ProtectedLabel
	 * @property QIntegerTextBox $PriorityControl
	 * @property-read QLabel $PriorityLabel
	 * @property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * @property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class MantisPluginTableMetaControlGen extends QBaseClass {
		// General Variables
		/**
		 * @var MantisPluginTable objMantisPluginTable
		 * @access protected
		 */
		protected $objMantisPluginTable;
		/**
		 * @var QForm|QControl objParentObject
		 * @access protected
		 */
		protected $objParentObject;
		/**
		 * @var string strTitleVerb
		 * @access protected
		 */
		protected $strTitleVerb;
		/**
		 * @var boolean blnEditMode
		 * @access protected
		 */
		protected $blnEditMode;

		// Controls that allow the editing of MantisPluginTable's individual data fields
		/**
		 * @var QTextBox txtBasename
		 * @access protected
		 */
		protected $txtBasename;
		/**
		 * @var QIntegerTextBox txtEnabled
		 * @access protected
		 */
		protected $txtEnabled;
		/**
		 * @var QIntegerTextBox txtProtected
		 * @access protected
		 */
		protected $txtProtected;
		/**
		 * @var QIntegerTextBox txtPriority
		 * @access protected
		 */
		protected $txtPriority;

		// Controls that allow the viewing of MantisPluginTable's individual data fields
		/**
		 * @var QLabel lblBasename
		 * @access protected
		 */
		protected $lblBasename;
		/**
		 * @var QLabel lblEnabled
		 * @access protected
		 */
		protected $lblEnabled;
		/**
		 * @var QLabel lblProtected
		 * @access protected
		 */
		protected $lblProtected;
		/**
		 * @var QLabel lblPriority
		 * @access protected
		 */
		protected $lblPriority;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * MantisPluginTableMetaControl to edit a single MantisPluginTable object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single MantisPluginTable object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisPluginTableMetaControl
		 * @param MantisPluginTable $objMantisPluginTable new or existing MantisPluginTable object
		 */
		 public function __construct($objParentObject, MantisPluginTable $objMantisPluginTable) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this MantisPluginTableMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked MantisPluginTable object
			$this->objMantisPluginTable = $objMantisPluginTable;

			// Figure out if we're Editing or Creating New
			if ($this->objMantisPluginTable->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to
		 * edit, or if we are also allowed to create a new one, etc.
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisPluginTableMetaControl
		 * @param string $strBasename primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing MantisPluginTable object creation - defaults to CreateOrEdit
 		 * @return MantisPluginTableMetaControl
		 */
		public static function Create($objParentObject, $strBasename = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($strBasename)) {
				$objMantisPluginTable = MantisPluginTable::Load($strBasename);

				// MantisPluginTable was found -- return it!
				if ($objMantisPluginTable)
					return new MantisPluginTableMetaControl($objParentObject, $objMantisPluginTable);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a MantisPluginTable object with PK arguments: ' . $strBasename);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new MantisPluginTableMetaControl($objParentObject, new MantisPluginTable());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisPluginTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisPluginTable object creation - defaults to CreateOrEdit
		 * @return MantisPluginTableMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$strBasename = QApplication::PathInfo(0);
			return MantisPluginTableMetaControl::Create($objParentObject, $strBasename, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisPluginTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisPluginTable object creation - defaults to CreateOrEdit
		 * @return MantisPluginTableMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$strBasename = QApplication::QueryString('strBasename');
			return MantisPluginTableMetaControl::Create($objParentObject, $strBasename, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QTextBox txtBasename
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtBasename_Create($strControlId = null) {
			$this->txtBasename = new QTextBox($this->objParentObject, $strControlId);
			$this->txtBasename->Name = QApplication::Translate('Basename');
			$this->txtBasename->Text = $this->objMantisPluginTable->Basename;
			$this->txtBasename->Required = true;
			$this->txtBasename->MaxLength = MantisPluginTable::BasenameMaxLength;
			return $this->txtBasename;
		}

		/**
		 * Create and setup QLabel lblBasename
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblBasename_Create($strControlId = null) {
			$this->lblBasename = new QLabel($this->objParentObject, $strControlId);
			$this->lblBasename->Name = QApplication::Translate('Basename');
			$this->lblBasename->Text = $this->objMantisPluginTable->Basename;
			$this->lblBasename->Required = true;
			return $this->lblBasename;
		}

		/**
		 * Create and setup QIntegerTextBox txtEnabled
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtEnabled_Create($strControlId = null) {
			$this->txtEnabled = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtEnabled->Name = QApplication::Translate('Enabled');
			$this->txtEnabled->Text = $this->objMantisPluginTable->Enabled;
			$this->txtEnabled->Required = true;
			return $this->txtEnabled;
		}

		/**
		 * Create and setup QLabel lblEnabled
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblEnabled_Create($strControlId = null, $strFormat = null) {
			$this->lblEnabled = new QLabel($this->objParentObject, $strControlId);
			$this->lblEnabled->Name = QApplication::Translate('Enabled');
			$this->lblEnabled->Text = $this->objMantisPluginTable->Enabled;
			$this->lblEnabled->Required = true;
			$this->lblEnabled->Format = $strFormat;
			return $this->lblEnabled;
		}

		/**
		 * Create and setup QIntegerTextBox txtProtected
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtProtected_Create($strControlId = null) {
			$this->txtProtected = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtProtected->Name = QApplication::Translate('Protected');
			$this->txtProtected->Text = $this->objMantisPluginTable->Protected;
			$this->txtProtected->Required = true;
			return $this->txtProtected;
		}

		/**
		 * Create and setup QLabel lblProtected
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblProtected_Create($strControlId = null, $strFormat = null) {
			$this->lblProtected = new QLabel($this->objParentObject, $strControlId);
			$this->lblProtected->Name = QApplication::Translate('Protected');
			$this->lblProtected->Text = $this->objMantisPluginTable->Protected;
			$this->lblProtected->Required = true;
			$this->lblProtected->Format = $strFormat;
			return $this->lblProtected;
		}

		/**
		 * Create and setup QIntegerTextBox txtPriority
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtPriority_Create($strControlId = null) {
			$this->txtPriority = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtPriority->Name = QApplication::Translate('Priority');
			$this->txtPriority->Text = $this->objMantisPluginTable->Priority;
			$this->txtPriority->Required = true;
			return $this->txtPriority;
		}

		/**
		 * Create and setup QLabel lblPriority
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblPriority_Create($strControlId = null, $strFormat = null) {
			$this->lblPriority = new QLabel($this->objParentObject, $strControlId);
			$this->lblPriority->Name = QApplication::Translate('Priority');
			$this->lblPriority->Text = $this->objMantisPluginTable->Priority;
			$this->lblPriority->Required = true;
			$this->lblPriority->Format = $strFormat;
			return $this->lblPriority;
		}



		/**
		 * Refresh this MetaControl with Data from the local MantisPluginTable object.
		 * @param boolean $blnReload reload MantisPluginTable from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objMantisPluginTable->Reload();

			if ($this->txtBasename) $this->txtBasename->Text = $this->objMantisPluginTable->Basename;
			if ($this->lblBasename) $this->lblBasename->Text = $this->objMantisPluginTable->Basename;

			if ($this->txtEnabled) $this->txtEnabled->Text = $this->objMantisPluginTable->Enabled;
			if ($this->lblEnabled) $this->lblEnabled->Text = $this->objMantisPluginTable->Enabled;

			if ($this->txtProtected) $this->txtProtected->Text = $this->objMantisPluginTable->Protected;
			if ($this->lblProtected) $this->lblProtected->Text = $this->objMantisPluginTable->Protected;

			if ($this->txtPriority) $this->txtPriority->Text = $this->objMantisPluginTable->Priority;
			if ($this->lblPriority) $this->lblPriority->Text = $this->objMantisPluginTable->Priority;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC MANTISPLUGINTABLE OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's MantisPluginTable instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveMantisPluginTable() {
			try {
				// Update any fields for controls that have been created
				if ($this->txtBasename) $this->objMantisPluginTable->Basename = $this->txtBasename->Text;
				if ($this->txtEnabled) $this->objMantisPluginTable->Enabled = $this->txtEnabled->Text;
				if ($this->txtProtected) $this->objMantisPluginTable->Protected = $this->txtProtected->Text;
				if ($this->txtPriority) $this->objMantisPluginTable->Priority = $this->txtPriority->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the MantisPluginTable object
				$this->objMantisPluginTable->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's MantisPluginTable instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteMantisPluginTable() {
			$this->objMantisPluginTable->Delete();
		}



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'MantisPluginTable': return $this->objMantisPluginTable;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to MantisPluginTable fields -- will be created dynamically if not yet created
				case 'BasenameControl':
					if (!$this->txtBasename) return $this->txtBasename_Create();
					return $this->txtBasename;
				case 'BasenameLabel':
					if (!$this->lblBasename) return $this->lblBasename_Create();
					return $this->lblBasename;
				case 'EnabledControl':
					if (!$this->txtEnabled) return $this->txtEnabled_Create();
					return $this->txtEnabled;
				case 'EnabledLabel':
					if (!$this->lblEnabled) return $this->lblEnabled_Create();
					return $this->lblEnabled;
				case 'ProtectedControl':
					if (!$this->txtProtected) return $this->txtProtected_Create();
					return $this->txtProtected;
				case 'ProtectedLabel':
					if (!$this->lblProtected) return $this->lblProtected_Create();
					return $this->lblProtected;
				case 'PriorityControl':
					if (!$this->txtPriority) return $this->txtPriority_Create();
					return $this->txtPriority;
				case 'PriorityLabel':
					if (!$this->lblPriority) return $this->lblPriority_Create();
					return $this->lblPriority;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to MantisPluginTable fields
					case 'BasenameControl':
						return ($this->txtBasename = QType::Cast($mixValue, 'QControl'));
					case 'EnabledControl':
						return ($this->txtEnabled = QType::Cast($mixValue, 'QControl'));
					case 'ProtectedControl':
						return ($this->txtProtected = QType::Cast($mixValue, 'QControl'));
					case 'PriorityControl':
						return ($this->txtPriority = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>